<template>
  <div style="overflow: auto; margin: 20px" v-loading="loading">
    <el-form label-position="right" label-width="100px">
      <el-form-item label="app标志">
        <el-input
          placeholder="请输入app标志"
          v-model="policy.PPC_App"
          style="width: 200px; margin-left: 10px"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="内容">
        <myEditor
          v-model="mainEditor"
          @input="
            () => {
              policy.PPC_Content = mainEditor.html
              policy.PPC_ContentTxt = mainEditor.text
            }
          "
          :buttonVis="false"
          style="height: 80vh"
        ></myEditor>
      </el-form-item>
    </el-form>
    <div class="btnDiv">
      <el-button
        type="primary"
        round
        size="medium"
        class="btn"
        icon="el-icon-goods"
        @click="addPrivacyPolicy"
      >
        新增
      </el-button>
    </div>
  </div>
</template>
<script>
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import myEditor from '@/views/components/my-editor'
import { addPrivacyPolicy } from '@/api/common/privacyPolicy'

export default {
  data: function () {
    return {
      loading: false,
      mainEditor: {},
      policy: {},
    }
  },
  components: {
    myEditor,
  },
  methods: {
    addPrivacyPolicy() {
      this.loading = true
      addPrivacyPolicy(this.policy)
        .then(() => {
          this.loading = false
          this.$router.go(-1)
        })
        .catch(() => {
          this.loading = false
        })
    },
  },
  created: function () {},
}
</script>
<style>
.ql-editor {
  padding: 0;
}
</style>

<style scoped>
.btnDiv {
  height: 80px;
  font-size: 20px;
  position: fixed;
  display: flex;
  bottom: 110px;
  right: 50px;
  z-index: 1000;
}

.upload-button {
  width: 400px;
  height: 200px;
  background-color: #f3f3f3;
  font-size: 16px;
  color: #5f85f6;
  margin-right: 16px;
  margin-bottom: 10px;
}
</style>
